package com.pengyang.netty.demo.util;

import org.msgpack.MessagePack;

import com.pengyang.netty.demo.pojo.IMMessage;
import com.pengyang.netty.demo.pojo.SelfDefinedProtocol;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;

/**
* @ClassName: SelfDefinedEncoder  
* @author peng.yang
* @date 2018年5月9日 下午1:21:11 
* @Description:
  
 */
public class SelfDefinedEncoder extends MessageToByteEncoder<IMMessage> {

	@Override
	protected void encode(ChannelHandlerContext ctx, IMMessage  msg, ByteBuf out) throws Exception {
		 out.writeBytes(new MessagePack().write(msg));
	}

}
